package com.example.myapplication.apter;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.myapplication.Config.TokenBean;
import com.example.myapplication.R;
import com.example.myapplication.ShuJu.VolunteerNewslistBean;


import java.util.List;

public class MsvieinNewslistApter  extends RecyclerView.Adapter<MsvieinNewslistApter.MyHolder> {
    private Context context;
    private List<VolunteerNewslistBean.RowsBean> rowsBeanList;
    private String TAG = "TAG";

    public MsvieinNewslistApter(Context context, List<VolunteerNewslistBean.RowsBean> list) {
        this.context = context;
        this.rowsBeanList = list;
    }


    @NonNull
    @Override
    public MsvieinNewslistApter.MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_newdislist, null);
        return new MsvieinNewslistApter.MyHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MsvieinNewslistApter.MyHolder holder, int position) {
        //志愿活动
            Glide.with(context).load(TokenBean.IP+rowsBeanList.get(position).getImgUrl()).into(holder.newsdislist_img);
            Log.e(TAG,TokenBean.IP+rowsBeanList.get(position).getImgUrl());
            holder.newsdislist_img.setScaleType(ImageView.ScaleType.FIT_XY);
            holder.newsdislist_title.setText(rowsBeanList.get(position).getTitle());
            holder.newsdislist_link.setVisibility(View.INVISIBLE);
            holder.newsdislist_dianzeng.setText(rowsBeanList.get(position).getCreateTime());

    }

    @Override
    public int getItemCount() {
        return rowsBeanList==null?0:rowsBeanList.size();
    }

    class MyHolder extends RecyclerView.ViewHolder {
        ImageView newsdislist_img;
        TextView newsdislist_title;
        TextView newsdislist_link;
        TextView newsdislist_dianzeng;
        RelativeLayout re_newsdislist;

        public MyHolder(@NonNull View itemView) {
            super(itemView);
            newsdislist_img = itemView.findViewById(R.id.newsdislist_img);
            newsdislist_title = itemView.findViewById(R.id.newsdislist_title);
            newsdislist_link = itemView.findViewById(R.id.newsdislist_link);
            newsdislist_dianzeng = itemView.findViewById(R.id.newsdislist_dianzeng);
            re_newsdislist = itemView.findViewById(R.id.re_newsdislist);

        }
    }
}




